<?php
include_once 'library/Bootstrap/ModuleBootstrap.php';
class AdministratorBootstrap extends ModuleBootstrap{

	public function _init(){
		/*////////////////////////////////////*/
//		$pattern = '/\/(.*)/';
//		$route = new Route(
//					"controler", 
//					$pattern, 
//					array(
//						Configuration::CONTROLLER => '$1',
//						Configuration::ACTION=>Configuration::ACTION_DEFAULT,
//						Configuration::VIEW=>Configuration::VIEW_DEFAULT,
//						Configuration::VIEW_TYPE=>Configuration::VIEW_TYPE_DEFAULT
//					)
//		);
//		$this->addRoute($route);
		/*////////////////////////////////////*/
		$pattern = '/\/(.*)\/(.*)\/(.*)\.(.*)/';
		$route = new Route(
					"controler/action/view.viewtype", 
					$pattern, 
					array(
						Configuration::CONTROLLER => '$1',
						Configuration::ACTION=>'$2',
						Configuration::VIEW=>'$3',
						Configuration::VIEW_TYPE=>'$4'
					)
		);
		$this->addRoute($route);
		/*////////////////////////////////////*/
		$pattern = '/\/product\/(.*)/';
		$route = new Route(
					"product details", 
					$pattern, 
					array(
						Configuration::CONTROLLER => 'Product',
						Configuration::ACTION=>Configuration::ACTION_DEFAULT,
						Configuration::VIEW=>Configuration::VIEW_DEFAULT,
						Configuration::VIEW_TYPE=>Configuration::VIEW_TYPE_DEFAULT,
						'productid'=>'$1'
					)
		);
		$this->addRoute($route);
	}
	/**
	 * (non-PHPdoc)
	 * @see library/Bootstrap/ModuleBootstrap::_auth()<br>
	 * Module Autenication.
	 */
	public function _auth($route){
		if(!Auth::hasSession()){
			$route[Configuration::CONTROLLER] = "UserSystem";
			$route[Configuration::ACTION] = "login";
			$route[Configuration::VIEW] = "default";
			$route[Configuration::VIEW_TYPE] = "html";
		}
		return $route;
	}
}